import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { ObjCreate } from "../common/ObjCreate";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
type int = number;
//class RomanicView
    
    export  class RomanicView extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.resetPosition();
            this.createChildren();
            this.mouseEnabled = false;
            this.mouseChildren = false;
            return;
        }

        /* internal  */createChildren(): void
        {
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 15788607);
            loc1.bold = true;
            var loc2=new Object /* flash.display.Sprite */();
            this.addChild(loc2);
            this._bmpProgressOverData = GlobalClass.getBitmapData(ImagesConst.RomanicOver);
            this._bmpdProgress = this._bmpProgressOverData.clone();
            this._fireProgressBg = new Object /* flash.display.Bitmap */();
            this._fireProgressBg.x = 49;
            this._fireProgressBg.y = 20;
            loc2.addChild(this._fireProgressBg);
            this._bmpProgress = new Object /* flash.display.Bitmap */();
            this._bmpProgress.x = 49;
            this._bmpProgress.y = 27;
            loc2.addChild(this._bmpProgress);
            this._fireProgressLeft = new Object /* flash.display.Bitmap */();
            loc2.addChild(this._fireProgressLeft);
            this._fireProgressRight = new Object /* flash.display.Bitmap */();
            this._fireProgressRight.x = 180;
            loc2.addChild(this._fireProgressRight);
            this._bmpProgressLight = new Object /* flash.display.Bitmap */();
            this._bmpProgressLight.x = 25;
            this._bmpProgressLight.y = 10;
            loc2.addChild(this._bmpProgressLight);
            this._tfProgress = ObjCreate.createTextField("浪漫度：0/1314", 60, 8, 130, 20, loc2, GlobalStyle.textFormat2);
            LoaderHelp.addResCallBack("romanic", this.updateBitmapData);
            return;
        }

        /* internal  */updateBitmapData(): void
        {
            this._fireProgressBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.RomanicBg);
            this._fireProgressLeft.bitmapData = GlobalClass.getBitmapData(ImagesConst.RomanicLeft);
            this._fireProgressRight.bitmapData = GlobalClass.getBitmapData(ImagesConst.RomanicRight);
            this._bmpProgressLight.bitmapData = GlobalClass.getBitmapData(ImagesConst.RomanicLight);
            return;
        }

        public updateRomanic(arg1: int, arg2: int): void
        {
            var loc1=NaN;
            loc1 = arg1 / arg2;
            loc1 = loc1 < 0 ? 0 : loc1;
            loc1 = loc1 > 1 ? 1 : loc1;
            var loc2=0;
            this._bmpProgress.bitmapData = null;
            this._bmpdProgress.dispose();
            if (loc1 > 0) 
            {
                if ((loc2 = loc1 * this._bmpProgressOverData.width) >= 1) 
                {
                    this._bmpdProgress = new Object /* flash.display.BitmapData */(loc2, this._bmpProgressOverData.height, true, 16777215);
                    this._bmpdProgress.draw(this._bmpProgressOverData, null, null, null, new Object /* flash.geom.Rectangle */(0, 0, loc2, this._bmpProgressOverData.height));
                    this._bmpProgress.bitmapData = this._bmpdProgress;
                }
            }
            this._bmpProgressLight.x = loc2 + 30;
            this._tfProgress.text = this._desText + "：" + arg1 + "/" + arg2;
            return;
        }

        public set desText(arg1: string)
        {
            this._desText = arg1;
            return;
        }

        public resetPosition(): void
        {
            this.x = 260;
            this.y = 10;
            return;
        }

        /* internal */ /* var */_tfProgress: Object /* flash.text.TextField */;

        /* internal */ /* var */_bmpProgressOverData: Object /* flash.display.BitmapData */;

        /* internal */ /* var */_bmpProgressLight: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpProgress: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_bmpdProgress: Object /* flash.display.BitmapData */;

        /* internal */ /* var */_fireProgressLeft: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_fireProgressRight: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_fireProgressBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_desText: string="浪漫度";
    }
